package com.jt.service;

import com.jt.mapper.UserMapper;
import com.jt.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;

    @Override
    @Transactional
    public List<User> findAll(User user) {
       List<User>userList= userMapper.findAll(user);
        return userList ;
    }

    @Override
    @Transactional
    public void saveUser(User user) {
        userMapper.saveUser(user);
    }

    @Override
    @Transactional
    public void deleteUserById(User user) {
        userMapper.deleteUserById(user);
    }

    @Override
    @Transactional
    public void update(User user) {
        userMapper.update(user);
    }

    @Override
    @Transactional
    public List<User> findUserById(User user) {
        List<User> userList= userMapper.findUserById(user);
        return userList;
    }

    @Override
    public List<User> findUserByLike(User user) {
        List<User> userList=  userMapper.findUserByLike(user);
        return userList;
    }

    @Override
    public List<User> findUserByIn(Integer[] id){
        List<User>userList= userMapper.findUserByIn(id);
        return userList;
    }

    @Override
    public List<User> findUserByIn1(@Param("minAge")Integer minAge,
                                    @Param("maxAge")Integer maxAge) {
       List<User>userList= userMapper.findUserByIn1(minAge, maxAge);
        return userList;
    }
}
